package com.rem.designPattern.factory工厂方法.simpleFactory;

/**
 * @author Rem
 * @date 2022-11-14
 */
public class CoffeeStore {

    /**
     * 简单工厂创建咖啡
     *
     * @param type
     * @return
     */
    public Coffee orderCoffee(String type) {
        SimpleCoffeeFactory factory = new SimpleCoffeeFactory();
        //调用生产咖啡的方法
        Coffee coffee = factory.createCoffee(type);

        //加配料
        coffee.addMilk();
        coffee.addsugar();

        return coffee;
    }

    /**
     * 静态工厂创建咖啡
     *
     * @param type
     * @return
     */
    public Coffee orderCoffee2(String type) {
        Coffee coffee = SimpleCoffeeFactory.createCoffee2(type);

        //加配料
        coffee.addMilk();
        coffee.addsugar();

        return coffee;
    }
}